Security News
UK Officials Consider Banning Ransomware Payments from Public Entities
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
@phensley/decimal
Advanced tools
Arbitrary precision decimal math, used to support @phensley/cldr, but can be used by itself.
NPM:
npm install --save @phensley/decimal
Yarn:
yarn add @phensley/decimal
import { Decimal, DecimalConstants, MathContext } from '@phensley/decimal';
const area = (radius: Decimal, ctx: MathContext) =>
DecimalConstants.PI.multiply(radius, ctx).multiply(radius, ctx);
const calc = (ctx: MathContext) => {
for (const r of ['.002', '1', '1.5', '999.999']) {
const radius = new Decimal(r);
console.log(
`area of circle with radius ${r.padEnd(7)} is ${area(radius, ctx)}`
);
}
console.log();
};
for (const scale of [5, 15]) {
console.log(`Scale ${scale}:`);
calc({ scale });
}
for (const precision of [10, 30]) {
console.log(`Precision ${precision}:`);
calc({ precision });
}
const LIGHT_YEAR_KM = new Decimal('9.461e12');
const NEAREST_STARS: any = {
'Proxima Centauri': '4.32',
"Barnard's Star": '5.96',
'Wolf 359': '7.78',
'Lalande 21185': '8.29'
};
for (const name of Object.keys(NEAREST_STARS)) {
const distly = NEAREST_STARS[name];
const distkm = new Decimal(distly).multiply(LIGHT_YEAR_KM, { precision: 30 });
console.log(
`Distance to ${name.padEnd(16)} is ${distkm.toString()} kilometers`
);
}
Scale 5:
area of circle with radius .002 is 0.00001
area of circle with radius 1 is 3.14159
area of circle with radius 1.5 is 7.06858
area of circle with radius 999.999 is 3141586.36841
Scale 15:
area of circle with radius .002 is 0.000012566370614
area of circle with radius 1 is 3.141592653589793
area of circle with radius 1.5 is 7.068583470577035
area of circle with radius 999.999 is 3141586.370407627651860
Precision 10:
area of circle with radius .002 is 0.00001256637061
area of circle with radius 1 is 3.141592654
area of circle with radius 1.5 is 7.068583470
area of circle with radius 999.999 is 3141586.370
Precision 30:
area of circle with radius .002 is 0.0000125663706143591729538505735331
area of circle with radius 1 is 3.14159265358979323846264338328
area of circle with radius 1.5 is 7.06858347057703478654094761238
area of circle with radius 999.999 is 3141586.37040762765152975625124
Distance to Proxima Centauri is 40871520000000 kilometers
Distance to Barnard's Star is 56387560000000 kilometers
Distance to Wolf 359 is 73606580000000 kilometers
Distance to Lalande 21185 is 78431690000000 kilometers
FAQs
Arbitrary precision decimal math
We found that @phensley/decimal demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.